﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Qiang.Data
{
    [Serializable]
    public abstract class Dataset :IDataset
    {

        public Dataset()
        { 
            
        }


        #region 属性

        
        /// <summary>
        /// 数据集范围
        /// </summary>
        public IExtent Extent
        {
            get 
            {
                return this.ComputeExtent();               
            }
        }


        #endregion


        #region 虚方法

        /// <summary>
        /// 获取数据集的范围
        /// </summary>
        /// <returns></returns>
        protected virtual IExtent ComputeExtent()
        {
            return Qiang.Data.Extent.Empty();
        }

        #endregion


        #region 释放资源


        private bool _disposed;

        /// <summary>
        /// 指示是否释放
        /// </summary>
        public bool Disposed
        {
            get { return _disposed; }
            set { _disposed = value; }
        }


        /// <summary>
        /// 析构函数。只释放托管代码
        /// </summary>
        ~Dataset()
        {
            Dispose(false);
        }

        /// <summary>
        /// 不管是托管还是非托管内存全部释放
        /// </summary>
        public void Dispose()
        {
            if (_disposed) return;

            Dispose(true);

            _disposed = true;

        }
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isDisposing">指示是否释放非托管资源</param>
        protected virtual void Dispose(bool isDisposing)
        { 

        }



        #endregion




    }
}
